<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加制卡批次</title>
<link rel="stylesheet" type="text/css" href="admin/css/style.css" />
<link rel="stylesheet" type="text/css" media="all" href="admin/css/niceforms-default.css" />
<link rel="stylesheet" type="text/css" media="all" href="admin/js/date/jquery-ui-1.8.16.custom.css" />
<script type="text/javascript" src="admin/js/jquery.min.js"></script>
<script type="text/javascript" src="admin/js/niceforms.js"></script>
<script type="text/javascript" src="admin/js/ddaccordion.js"></script>
<script type="text/javascript" src="admin/js/jconfirmaction.jquery.js"></script>
<script type="text/javascript" src="admin/js/jquery.jclock-1.2.0.js"></script>
<script type="text/javascript" src="admin/js/date/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="admin/js/date/jquery.ui.datepicker-zh-CN.js"></script>

<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [1], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='<%=basePath%>admin/images/plus.gif' class='statusicon' />", "<img src='<%=basePath%>admin/images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
});
</script>
<script type="text/javascript">
<%--	$(document).ready(function() {--%>
<%--		$('.ask').jConfirmAction();--%>
<%--	});--%>
	
	$(function() {
	    $('.jclock').jclock();
	});
</script>
<script>
	
	function getCardFlag(issuerId) {
		if(issuerId == -1) {
			$('#cardFlag').html("卡号段");
			return;
		}
		$.ajax({ 
	        type: "post", 
	        url: "issuerAction!getFlagById", 
	        data: "issuer.cardIssuerId=" + issuerId, 
	        success: function(responseText){ 
				//alert(responseText);
	            $('#cardFlag').html(responseText); 
	        } 
        }); 
	}
	
	function TextBoxOnlyNums(textboxObj) {
		textboxObj.value = textboxObj.value.replace(/[^0-9]/g, '');
	}
	
	function validate() {
		var cardIssuerId = $('#cardIssuerId').val();
		if(cardIssuerId == -1) {
			$('#error').html("请选择发卡商!");
			return false;
		}
		var materialType = $('#materialType').val();
		if(materialType == -1) {
			$('#error').html("请选择卡类型!");
			return false;
		}
		var num = $('#num').val();
		var np = /^\+?[1-9][0-9]*$/;
		if(!np.exec(num)){
			$('#error').html("请输入正确的卡数!");
			$('#num').focus();
			return false;
		}
		var faceValue = $('#faceValue').val();
		var vp = /^[0-9]+(.[0-9]{2})?$/;
		if(!vp.exec(faceValue)) {
			$('#error').html("请输入正确的面值，包含两位小数!");
			$('#faceValue').attr('value', '0.00');
			$('#faceValue').focus();
			return false;
		}
		
		var sb = $('#sectionBegin').val();
		var se = $('#sectionEnd').val();
		if(sb == '' && se == '') {
			if(!confirm("卡号后9为由系统自动生成?")) {
				$('#sectionBegin').focus();
				return false;
			} else {
				return true;
			}
		}
		if(sb.length != se.length) {
			$('#error').html("起始卡号位数长度必须相等!");
			$('#sectionBegin').focus();
			return false;
		}
		return true;
	}
	
	function addBatch() {
		if(validate()) {
			document.addForm.submit();
		}
	}
	
</script>

</head>

<body>
<div id="main_container">
       <%@include file="../header.jsp"%>
    <div class="main_content">
         <%@include file="menu.jsp"%>
   		 <div class="center_content">  
  		  <div class="left_content">
  				   <%@include file="sidebarmenu_sys.jsp"%>
    	  </div>  
    
		    <div class="right_content">            
		        
		    	<h5>当前位置: 卡系统 &gt; 制卡批次管理 &gt; 添加制卡批次</h5>  
		      
		        
		        
		        <form action="cardBatch!addBatch" id="addForm" name="addForm" method="post">
				<table id="rounded-corner" summary="2007 Major IT Companies' Profit">
				    <thead>
				    	<tr>
				        	<th scope="col" class="rounded-company" width="5%"></th>
				            <th scope="col" class="rounded" width="15%"></th>
				            <th scope="col" class="rounded" width="30%" align="right">添加制卡批次</th>
				            <th scope="col" class="rounded" width="15%"></th>
				            <th scope="col" class="rounded" width="30%"></th>
				            <th scope="col" class="rounded-q4" width="5%"></th>
				        </tr>
				    </thead>
			        <tfoot>
			    		<tr>
			    			<td  class="rounded-foot-left"></td>
				        	<td></td>
				        	<td>
				            	<a href="javascript:addBatch();" class="bt_blue">
		         					<span class="bt_blue_lft"></span><strong>添加</strong><span class="bt_blue_r"></span>
		        				</a>
				            </td>
				            <td>
				            	<a href="javascript:history.back(-1);" class="bt_blue">
		         					<span class="bt_blue_lft"></span><strong>返回</strong><span class="bt_blue_r"></span>
		        				</a>
				            </td>
				        	<td></td>
				        	<td class="rounded-foot-right">&nbsp;</td>
				        </tr>
				    </tfoot>
				    <tbody>
				    	<tr>
				    		<td colspan="6"></td>
				    	</tr>
				    	<tr>
				        	<td></td>
				            <td align="right">发卡商：</td>
				            <td align="left">
				            	<s:select list="cardIssuers" listKey="cardIssuerId" listValue="name" value="" headerKey="-1" headerValue=" -- 请选择 -- " 
				            		name="cardBatch.cardIssuer.cardIssuerId" id="cardIssuerId" theme="simple" cssStyle="font-size:12px;"  onchange="getCardFlag(this.value);"></s:select>
				            	<font color="red">*</font>
				            </td>
				            <td align="right">卡类型：</td>
				            <td align="left">
				            	<s:select list="#application.dics.DIC_CARD_MATERIAL_TYPE" listKey="value" listValue="name" value="" headerKey="-1" headerValue=" -- 请选择 -- " 
				            		name="cardBatch.materialType" id="materialType" theme="simple" cssStyle="font-size:12px;"></s:select>
				            	<font color="red">*</font>
				            </td>
				            <td></td>
				        </tr>   
				        <tr>
				        	<td></td>
				            <td align="right">张  数：</td>
				            <td align="left"><input type="text" name="cardBatch.num" id="num" value="1" size="18" maxlength="4" title="请输入整数"/> <font color="red">*</font></td>
				            <td align="right">面  值：</td>
				            <td align="left"><input type="text" name="faceValue" id="faceValue" value="0.00" size="18" maxlength="10" title="精确到小数点后两位" /> (￥) <font color="red">*</font></td>
				            <td></td>
				        </tr> 
				        <tr>
				        	<td></td>
				            <td align="right">卡  号：</td>
				            <td align="left" colspan="3">
				            	<label id="cardFlag">卡号段</label> - 
				            	From <input type="text" name="cardBatch.sectionBegin" id="sectionBegin" value="" size="12" maxlength="9" title="请输入起始卡号，不足9位，后自动补0" onblur="TextBoxOnlyNums(this)"/>
				            	 To  <input type="text" name="cardBatch.sectionEnd" id="sectionEnd" value="" size="12" maxlength="9" title="请输入结束卡号，不足9位，后自动补0" onblur="TextBoxOnlyNums(this)" />
				            </td>
				            <td></td>
				        </tr> 
				        <tr>
				        	<td></td>
				            <td align="right">描  述：</td>
				            <td align="left"  colspan="3">
				            	<input type="text" name="cardBatch.batchDesc" id="batchDesc" value="" size="50" maxlength="100" />
				            </td>
				            <td></td>
				        </tr>
				        <tr>
				        	<td colspan="2"></td>
				            <td colspan="2" align="left">
				            	<label id="error" class="error"></label>
				            	<span class="error"><s:fielderror></s:fielderror></span>
				            </td>
				            <td colspan="2"></td>
				        </tr>  
				    </tbody>
				</table>
				</form>
		        
			</div>  <!-- end of right content-->
                    
		</div>  <!--end of center content -->               
    
		<div class="clear"></div>
	
    </div>  <!--end of main content-->
	
    
    <%@include file="../footer.jsp" %>

</div>		
</body>
</html>